package com.tax.config.jwt;

import com.auth0.jwt.interfaces.Claim;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;

import java.util.HashMap;
import java.util.Map;

/**
 * @ClassName JwtUserInfo
 * @Author lim@udiannet.com
 * @DATE 2019-09-10
 * @Version 1.0
 **/
@Data
public class JwtUserInfo {
    /**
     *全局用户uid
     */
    private String userId;

    private String telephone;

    /**
     * sub : 11
     * exp : 1568184340
     * iat : 1568166340
     * jti : 1568166340212
     */

    private String sub;
    private Integer exp;
    private String jti;

    @ApiModelProperty(value = "签发时间")
    private Integer iat;
    @ApiModelProperty(value = "设备id")
    private String deviceId;

    @ApiModelProperty(value = "应用渠道id,xcx,ios,android,h5")
    private String appSys;

    @ApiModelProperty(value = "客户端版本号")
    private String appVersion;

    @ApiModelProperty(value = "用户登录类型")
    private String userLoginType;

    public HashMap<String,String> toMap(){
        HashMap<String, String> map = new HashMap<>(16);
        map.put("userId",userId);
        map.put("telephone",telephone);
        map.put("sub",sub);
        map.put("exp",null==exp? StringUtils.EMPTY:String.valueOf(exp));
        map.put("jti",jti);
        map.put("iat",null==iat? StringUtils.EMPTY:String.valueOf(iat));
        map.put("deviceId",deviceId);
        map.put("appSys",appSys);
        map.put("appVersion",appVersion);
        map.put("userLoginType",userLoginType);
        return map;
    }

}
